﻿<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local='clr-namespace:NczControlLibrary.Controls'
    xmlns:ctr='clr-namespace:NczControlLibrary.Controls'>
    <Style TargetType='ctr:IconPopButton'>
        <Setter Property='Template'>
            <Setter.Value>
                <ControlTemplate TargetType='ctr:IconPopButton'>
                    <Border Background='{TemplateBinding Background}' CornerRadius='{TemplateBinding CornerRadius}' BorderBrush='{TemplateBinding BorderBrush}' BorderThickness='{TemplateBinding BorderThickness}' Width='{TemplateBinding Width}' Height='{TemplateBinding Height}' Visibility='{TemplateBinding Property=Visibility}' HorizontalAlignment='Stretch' VerticalAlignment='Stretch' x:Name='fBorderRoot'>
                        <Border.RenderTransform>
                            <TranslateTransform/>
                        </Border.RenderTransform>
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name='vsg1'>
                                <VisualState x:Name='nomal'/>
                                <VisualState x:Name='mouseover'>
                                    <Storyboard>
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Fill).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(FrameworkElement.Background).(SolidColorBrush.Color)'/>
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Stroke).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fTextBlock' Storyboard.TargetProperty='(TextBlock.Foreground).(SolidColorBrush.Color)'/>
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Stroke).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fPath' Storyboard.TargetProperty='(Path.Stroke).(SolidColorBrush.Color)'/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name='mouseoverforpathfill'>
                                    <Storyboard>
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Fill).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(FrameworkElement.Background).(SolidColorBrush.Color)'/>
                                        <!--<ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Fill).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(FrameworkElement.BorderBrush).(SolidColorBrush.Color)'/>-->
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Stroke).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fTextBlock' Storyboard.TargetProperty='(TextBlock.Foreground).(SolidColorBrush.Color)'/>
                                        <ColorAnimation Duration='0' To='{Binding Path=(Rectangle.Stroke).(SolidColorBrush.Color),ElementName=fRectangle}' Storyboard.TargetName='fPath' Storyboard.TargetProperty='(Path.Fill).(SolidColorBrush.Color)'/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name='mouseleave'>
                                    <Storyboard>
                                        <ColorAnimation Duration='0' To='{Binding ElementName=fRectangle, Path=(Rectangle.Stroke).(SolidColorBrush.Color)}' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(Border.Background).(SolidColorBrush.Color)'/>
                                        <ColorAnimation Duration='0' To='{Binding ElementName=fRectangle, Path=(Rectangle.Stroke).(SolidColorBrush.Color)}' Storyboard.TargetName='fTextBlock' Storyboard.TargetProperty='(TextBlock.Foreground).(SolidColorBrush.Color)'/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name='vsg2'>
                                <VisualState x:Name='mouseleftbuttondown'>
                                    <Storyboard>
                                        <DoubleAnimation Duration='0:0:.05' To='.5d' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(Border.RenderTransform).(TranslateTransform.X)'/>
                                        <DoubleAnimation Duration='0:0:.05' To='.8d' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(Border.RenderTransform).(TranslateTransform.Y)'/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name='mouseleftbuttonup'>
                                    <!--<Storyboard>
                                        <DoubleAnimation Duration='0:0:.05' To='.5d' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(Border.RenderTransform).(TranslateTransform.X)'/>
                                        <DoubleAnimation Duration='0:0:.05' To='.8d' Storyboard.TargetName='fBorderRoot' Storyboard.TargetProperty='(Border.RenderTransform).(TranslateTransform.Y)'/>
                                    </Storyboard>-->
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Grid Margin='{TemplateBinding Padding}' Background='Transparent' x:Name='fGrid' HorizontalAlignment='Stretch' VerticalAlignment='Center'>
                            <Grid.RowDefinitions>
                                <RowDefinition Height='Auto' MaxHeight='35'/>
                                <RowDefinition Height='Auto'/>
                            </Grid.RowDefinitions>
                            <Grid Grid.Row='0' HorizontalAlignment='Center' VerticalAlignment='Center'>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width='Auto'/>
                                    <ColumnDefinition Width='Auto'/>
                                    <ColumnDefinition Width='Auto'/>
                                    <ColumnDefinition Width='Auto'/>
                                </Grid.ColumnDefinitions>
                                <Rectangle Width='{TemplateBinding Interval}' Height='0' Opacity='0' Grid.Column='2' x:Name='fRectangle' Fill='{TemplateBinding Enterground}' Stroke='{TemplateBinding Background}'/>
                                <Image Grid.Column='0' Stretch='None' HorizontalAlignment='Right' VerticalAlignment='Center' Visibility='{TemplateBinding ImgVisibility}' Source='{TemplateBinding ImageSource}' Margin='0' Effect='{TemplateBinding Property=ImageEffect}'/>
                                <Path x:Name='fPath' Grid.Column='1' HorizontalAlignment='Stretch' VerticalAlignment='Center' Visibility='{TemplateBinding PathVisibility}' Data='{TemplateBinding Property=Data}' Margin='0' Fill='{TemplateBinding Fill}' Effect='{TemplateBinding Property=PathEffect}' Stroke='{TemplateBinding Stroke}' StrokeThickness='{TemplateBinding StrokeThickness}' Stretch='{TemplateBinding Property=Stretch}' Width='{TemplateBinding Property=PathWidth}' Height='{TemplateBinding Property=PathHeight}' MaxWidth='{TemplateBinding Property=PathMaxWidth}' MaxHeight='{TemplateBinding Property=PathMaxHeight}'/>
                                <TextBlock x:Name='fTextBlock' Grid.Column='3' Padding='{TemplateBinding Property=TextPadding}' HorizontalAlignment='Left' VerticalAlignment='Center' FontWeight='{TemplateBinding FontWeight}' FontFamily='{TemplateBinding FontFamily}' Foreground='{TemplateBinding Foreground}' FontSize='{TemplateBinding FontSize}' Text='{TemplateBinding Text}'/>
                            </Grid>
                            <Popup IsOpen='{TemplateBinding PopIsOpen}' Grid.Row='1' FlowDirection='{TemplateBinding ContentFlowDirection}' HorizontalAlignment='Stretch' VerticalAlignment='Bottom'>
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition MaxHeight='10'/>
                                        <RowDefinition Height='Auto'/>
                                    </Grid.RowDefinitions>
                                    <Rectangle Grid.Row='0' Height='{TemplateBinding PopTopBarDistance}' Fill='{TemplateBinding PopTopBarFill}' HorizontalAlignment='Stretch' VerticalAlignment='Stretch'/>
                                    <ContentPresenter Grid.Row='1' VerticalAlignment='Stretch' HorizontalAlignment='Stretch' Content='{TemplateBinding Content}'/>
                                </Grid>
                            </Popup>
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</ResourceDictionary>
